﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Sites/Man/Main.master" AutoEventWireup="true" CodeFile="Section.aspx.cs" Inherits="Templates_Audit_Section" %>
<asp:Content ID="Contect2" ContentPlaceHolderID="javascript" runat="server">
    
    <script type="text/javascript">
        
        var saveChanges=false;

        $(document).ready(function() {
            //alert("Ready");
            $(".formItem :input ").live("click", function() {
                saveChanges = true;
            });
            $("a.removeItem").live("click", function() {
                saveChanges = true;
            });
            $("a.addItem").live("click", function() {
                saveChanges = true;
            });

            $(".btnSaveChanges").live("click", function() {
                saveChanges = false;
            });
            //alert("Done Ready");
            
        });

		window.onbeforeunload = function() {
			if (saveChanges==true)
			{
				return 'You may have unsaved changes!';
            }
        };
		
        function ajaxEnd(object, args) {
            $(".flashAndHide").fadeTo("slow", 0.33).fadeTo("slow", 1).fadeTo("slow", 0.33).fadeTo("slow", 1).fadeTo("slow", 0);
        }
    </script>
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="cphContent" Runat="Server">
    <div style="border-bottom: 3px solid gray;">
    <cex:RoundedBox ID="titleBox" Color="Grey" RoundedBottom="false" runat="server">
        <h2>My Audit<asp:Label ID="lblTitle" runat="server" /></h2>
    </cex:RoundedBox>
    </div>
        <asp:ListView ID="listSections" DataKeyNames="Id" runat="server">
        <LayoutTemplate>
            <div class="expandSectionsContainer">
                <asp:PlaceHolder ID="itemPlaceholder" runat="server" />    
            </div>
        </LayoutTemplate>
        
        <EmptyDataTemplate>No Sections</EmptyDataTemplate>
        
        <ItemTemplate>
            <div class="clearfix" style="background:#efebe0; border-bottom:3px solid gray">
                <h2><asp:HyperLink ID="lnk" NavigateUrl='<%# AcmsContext.GetUrl((string)Eval("Id", "~/MyCo2/ContinueAudit.aspx?Id={0}"))%>' Text='<%#Eval("Name") %>' runat="server" /></h2>
                <asp:Label id="lblValue" CssClass="titleRightArea" Text='<%# GetSectionValue(Container)%>' runat="server" />
                <asp:Label id="lblCompleted" CssClass="titleRightArea" Text='<%# GetSectionCompleted(Container) ? "Completed" : "Incomplete" %>' runat="server" />
            </div>
        </ItemTemplate>
        <SelectedItemTemplate>
            <asp:Panel ID="pnlUpdate" DefaultButton="btnSave" runat="server">
                <%--<telerik:RadAjaxPanel ID="ajaxPanel" LoadingPanelID="radLoadingPanel" runat="server">--%>
                    <div class="clearfix" style="background:#efebe0; border-bottom:3px solid gray">
                        <h2><span><%#Eval("Name") %></span></h2>
                        <asp:Label id="lblValue" CssClass="titleRightArea" Text='<%# GetSectionValue(Container)%>' runat="server" />
                        <asp:Label id="lblCompleted" CssClass="titleRightArea" Text='<%# GetSectionCompleted(Container) ? "Completed" : "Incomplete" %>' runat="server" />
                    </div>
                    
                    <div class="form">
                        <div class="colA clearfix alternate">
                            <cex:AuditQuestionContainer Id="containerQuestions" SectionId='<%#Eval("Id") %>' SiteId='<%#AcmsContext.SiteId%>' Audit='<%#Audit %>' runat="server" />
                            <%--<asp:PlaceHolder ID="phQuestions" runat="server" Visible="false" />--%>
	                        <%--<div class="col first">
	                            <asp:PlaceHolder ID="phQuestions1" runat="server" />
	                        </div>--%>
	                        <%--<div class="col">
		                        <asp:PlaceHolder ID="phQuestions2" runat="server" />
    		                </div>--%>
	                        <%--<div class="col last">
	                            <asp:PlaceHolder ID="phQuestions3" runat="server" />
	                        </div>--%>
                        </div>
                        <div class="colA clearfix">
	                        <ul class="col first">
	                            <li class="formItem" style="border:0px">
	                            </li>
	                        </ul>
	                        <ul class="col">
		                        <li class="formItem" style="border:0px"></li>
    		                </ul>
	                        <ul class="col last">
	                            <li class="formItem" style="border:0px">
	                                <asp:Button ID="Button1" runat="server" Text="Save Progress" CausesValidation="false" CommandName="SaveProgress" CssClass="btnSaveChanges"/>
                                    <asp:Button ID="btnSave" runat="server" Text="Submit" CausesValidation="true" ValidationGroup="Save" CommandName="Submit" CssClass="btnSaveChanges"/>
                                </li>
                                <li id="savedMessage" class="flashAndHide feedback validationError" runat="server" visible="false" enableviewstate="false">
                                    Sucessfully saved section!
                                </li>
	                        </ul>
                        </div>
                    </div>
               <%-- </telerik:RadAjaxPanel>--%>
            </asp:Panel>
        </SelectedItemTemplate>
    </asp:ListView>
    <asp:Panel ID="pnlComplete" runat="server" CssClass="feedback">
        <p>All sections in the audit are now complete. To mark this audit as complete click the button below.</p>
        <p><asp:Button ID="btnComplete" Text="Mark Audit Complete" runat="server" /></p>
    </asp:Panel>
     <telerik:RadAjaxLoadingPanel ID="radLoadingPanel" InitialDelayTime="0" MinDisplayTime="2" BackColor="LightGray" Transparency="10" Height="100%" Width="100%" runat="server" >
        <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>' style="border: 0px;" />
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadAjaxManager ID="ajaxManager1" DefaultLoadingPanelID="radLoadingPanel" EnableAJAX="true" ClientEvents-OnResponseEnd="ajaxEnd" runat="server">
    </telerik:RadAjaxManager>
</asp:Content>

